package mortal.game.control
{
    import flash.events.*;
    import modules.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GMController extends Controller
    {
        private var _gmModule:GMModule;

        public function GMController()
        {
            Dispatcher.addEventListener(EventName.MailSendGmReport, this.onMailSendGmReport);
            Dispatcher.addEventListener(EventName.MailSendGmReportSuccess, this.onMailSendGmReportSuccess);
            
        }

        override public function get view() : IView
        {
            return this.initView();
        }

        override protected function initView() : IView
        {
            if (this._gmModule == null)
            {
                this._gmModule = new GMModule();
                this._gmModule.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
            }
            return this._gmModule;
        }

        private function onAddedToStageHandler(event:Event) : void
        {
            
        }

        override protected function initServer() : void
        {
            
        }

        private function onMailSendGmReport(event:DataEvent) : void
        {
            var _loc_2:* = event.data["type"] as int;
            var _loc_3:* = event.data["title"] as String;
            var _loc_4:* = event.data["content"] as String;
            GameProxy.mailProxy.sendGmReport(_loc_2, _loc_3, _loc_4);
            
        }

        private function onMailSendGmReportSuccess(event:DataEvent) : void
        {
            this._gmModule.onSendSuccess();
            
        }

    }
}
